"""blogproject URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/4.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, re_path, include
from django.views.static import serve
from django.conf import settings
from app01.views import index, backend

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', index.index),
    path('news/', index.news),
    path('moods/', index.moods),
    path('login/', index.login),
    path('login/random_code/', index.get_random_code),
    path('register/', index.register),
    path('logout/', index.logout),
    path('history/', index.history),
    path('about/', index.about),
    # 文章详情页
    re_path(r'^article/(?P<nid>\d+)/', index.article),
    # 搜索文章
    re_path(r'search/', index.search),

    path('admin_home/', backend.admin_home),
    path('backend/', backend.backend),
    path('backend/add_article/', backend.add_article),
    path('backend/edit_avatar/', backend.edit_avatar),
    path('backend/reset_password/', backend.reset_password),
    path('backend/add_article/', backend.add_article),
    path('backend/cover_list/', backend.cover_list),  # 文章封面
    path('backend/avatar_list/', backend.avatar_list),  # 头像列表

    # 编辑文章
    re_path(r'^backend/edit_article/(?P<nid>\d+)/', backend.edit_article),
    # 路由分发,将所有以api开头的请求分发到api这个url.py中
    re_path(r'^api/', include('api.urls')),

    # media配置,用书上传路由配置
    re_path(r'media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),

]
